#include "sync.h"
#include "asm_utils.h"
#include "stdio.h"
#include "os_modules.h"

SpinLock::SpinLock()
{
    initialize();
}

void SpinLock::initialize()
{
    bolt = 0;
}

void SpinLock::lock()
{
    while(bolt)//一直询问bolt值,在此之前 do nothing
         {
             //not zero, wait
         }
         asm_atomic_exchange(&bolt);
}

void SpinLock::unlock()
{
    bolt = 0;
}
